#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MX = 49;
int n, m;
ll p[65];
void insert(ll x) {
  per(i, MX, 0) {
    if (x >> i) {
      if (p[i])
        x ^= p[i];
      else {
        p[i] = x;
        return;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, m) {
    string s;
    cin >> s;
    ll x = 0;
    for (char c : s) x = (x << 1) | (c == 'O' ? 1 : 0);
    insert(x);
  }
  int cnt = 0;
  per(i, MX, 0) if (p[i]) cnt++;
  ll ans = 1ll << cnt;
  cout << ans % 2008;
  return 0;
}